package cn.whuc.spark

import org.apache.spark.rdd.RDD
import org.apache.spark.{SparkConf, SparkContext}

object WordCount {
  def main(args: Array[String]): Unit = {
  // 1 创建sparkContext
    val sc: SparkContext = new SparkContext(
      new SparkConf()
      .setMaster("local[*]")
      .setAppName(" ")
    )

    // 2 编写代码
    val list: List[Int] = List(1, 2, 3, 4, 5)
    val value: RDD[Int] = sc.makeRDD(list)

    val value1: RDD[String] = sc.textFile("input")

    val value2: RDD[String] = sc.textFile("input/1.txt",3)

//    value1.collect().foreach(println)

    value2.saveAsTextFile("output01")

    // 3 关闭上下文对象
    sc.stop()
  }

}
